/*
 * @Author       : Darcy
 * @Date         : 2021-04-15 11:01:11
 * @LastEditors  : Darcy
 * @LastEditTime : 2021-04-15 19:29:44
 * @FilePath     : \HelloWorld\Cpp\Acwing\P5.cpp
 * @Description  : <(￣︶￣)↗[GO!]
 * https://github.com/Darcy-Zhang
 */
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, V;
    cin >> N >> V;
    vector<int> volumn, worth;
    volumn.push_back(0);
    worth.push_back(0);
    int temp1, temp2, temp3;
    for (int i = 0; i < N; ++i) {
        cin >> temp1 >> temp2 >> temp3;
        int count = 1;
        while (temp3 > count) {
            temp3 -= count;
            volumn.push_back(temp1 * count);
            worth.push_back(temp2 * count);
            count *= 2;
        }
        volumn.push_back(temp1 * temp3);
        worth.push_back(temp2 * temp3);
    }
    int solu[V + 1];
    for (int v = 0; v <= V; ++v)
        solu[v] = 0;
    for (int i = 1; i <= static_cast<int>(volumn.size()) - 1; ++i)
        for (int v = V; v >= volumn[i]; --v)
            solu[v] = max(solu[v], solu[v - volumn[i]] + worth[i]);
    cout << solu[V] << endl;
    return 0;
}
